package com.he.controller;

import com.he.domain.Result;
import com.he.domain.vo.BlogBackInfoVO;
import com.he.domain.vo.BlogInfoVO;
import com.he.service.BlogInfoService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author He
 * @version 1.0
 * @Date 2023/9/17 16:43
 * @Desc
 */
@Tag(name = "博客模块")
@RestController
public class BlogInfoController {

    @Resource
    private BlogInfoService blogInfoService;
    /**
     * 上传访客信息
     *
     * @return {@link Result<>}
     */
    @Operation(description = "上传访客信息")
    @PostMapping("/visitor")
    public Result<?> report() {
        blogInfoService.addViewCount();
        return Result.success();
    }

    /**
     * 博客信息
     *
     * @return {@link Result< BlogInfoVO >} 博客信息
     */
    @Operation(description = "博客信息")
    @GetMapping("/")
    public Result<?> getBlogInfo() {
        return Result.success(blogInfoService.getBlogInfo());
    }


    /**
     * 查看后台信息
     *
     * @return {@link Result< BlogBackInfoVO >} 后台信息
     */
    @Operation(description = "查看后台信息")
    @GetMapping("/admin")
    public Result<BlogBackInfoVO> getBlogBackInfo() {
        return Result.success(blogInfoService.getBlogBackInfo());
    }
}
